﻿namespace NJQuery {
	using System.ComponentModel;
	using System.Web.UI;

	/// <summary>
	/// Defines a baseline jQuery UI <see cref="Dialog"/> widget button.
	/// </summary>
	[ParseChildren(true), PersistChildren(false)]
	public abstract class DialogButtonBase : Control {


		#region Constructors

		/// <summary>
		/// Initializes a new instance of the <see cref="DialogButtonBase"/> class.
		/// </summary>
		protected DialogButtonBase() { }

		#endregion


		#region Properties

		/// <summary>
		/// Gets or sets the text used on the button.
		/// This text must be unique for the <see cref="Dialog"/> widget, or else the last item will overwrite the duplicates.
		/// </summary>
		[DefaultValue(""), Category("Appearance")]
		public virtual string Text {
			get { return ViewState["Text"] as string ?? string.Empty; }
			set { ViewState["Text"] = value; }
		}

		#endregion


		#region Methods

		/// <summary>
		/// Renders the client click script for the button.
		/// This method is used primarily by control developers.
		/// </summary>
		/// <param name="script">A <see cref="ScriptBuilder"/> that creates the output stream to render jQuery JavaScript on the client.</param>
		protected abstract void RenderOnClickScript(ScriptBuilder script);

		internal void RenderOnClickScriptInternal(ScriptBuilder script) {
			//Perform what would be done with an interface if interfaces worked as well as base controls in the ASPX designer.
			RenderOnClickScript(script);
		}

		#endregion


	}

}